<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <head>
        <title>Insert title here</title>
        <meta charset="UTF-8">
        <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
        <title>Hello, Bootstrap Table!</title>
        <meta charset="UTF-8">
        <title>Title</title>
        <script th:src="@{/js/jquery-3.2.1.min.js}"></script>
        <!-- 最新 Bootstrap4 核心 CSS 文件 -->
        <link href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

        <!--时间控件-->
        <link href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css"
              rel="stylesheet">
        <!-- bootstrap.bundle.min.js 用于弹窗、提示、下拉菜单，包含了 popper.min.js -->
        <script rel="stylesheet" th:src="@{/js/bootstrap.bundle.min.js} "></script>
        <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
        <script rel="stylesheet" th:src="@{/js/bootstrap.min.js}"></script>
        <!-- BootStrapValidator -->
        <link href="https://cdn.bootcss.com/jquery.bootstrapvalidator/0.5.3/css/bootstrapValidator.min.css"
              rel="stylesheet">
        <script src="https://cdn.bootcss.com/jquery.bootstrapvalidator/0.5.3/js/bootstrapValidator.min.js"
                type="text/javascript"></script>
        <!--时间控件-->
        <script th:src="@{/daterangepicker/moment.js}"></script>
        <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
        <script th:src="@{/js/functions.js}"></script>

    </head>
</head>
<body>
<div th:include="../templates/admin/top::headtop"></div>
<div class="container" id="content">
    <div class="row">
        <div th:include="../templates/admin/menu::headmenu"></div>
        <div class="col-md-10">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="row">
                        <h1 class="col-md-5">放映厅管理</h1>
                        <form class="form-inline" id="searchForm" role="form" th:action="@{/admin/findScreens}"
                              th:method="post">
                            <div class="form-group col-md-2 offset-1">
                                <input class="form-control input-sm" id="screens_name" name="screens_name" placeholder="放映厅名"
                                       th:value="${param.screens_name}"
                                       type="text"/>
                            </div>
                            <div class="form-group col-md-2">
                                <select class="form-control input-sm" id="film_type1" name="screens_type">
                                    <option value="">---不限制放映厅类别---</option>
                                    <option th:selected="${#strings.trim(param.screens_type)=='0'}" value="0">小型</option>
                                    <option th:selected="${#strings.trim(param.screens_type)=='1'}" value="1">中型</option>
                                    <option th:selected="${#strings.trim(param.screens_type)=='2'}" value="2">中型3D</option>
                                    <option th:selected="${#strings.trim(param.screens_type)=='3'}" value="3">大型</option>
                                    <option th:selected="${#strings.trim(param.screens_type)=='4'}" value="4">大型3D</option>
                                </select>
                            </div>
                            <div class="form-group col-md-1">
                                <button class="btn btn-primary btn-sm" type="submit">搜索</button>
                            </div>
                        </form>
                        <div class="form-group col-md-1">
                            <button class="btn btn-primary btn-sm" onclick="registerMadel()" type="submit">新增放映厅</button>
                        </div>
                    </div>
                </div>
                <table class="table table-bordered">
                    <thead>
                    <tr>
                    <tr>
                        <th>选项</th>
                        <th>#</th>
                        <th>放映厅号</th>
                        <th>坐位数</th>
                        <th>类型</th>
                        <th>操作</th>
                    </tr>

                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="u,stat:${ScreensList}">
                        <td><input name="chk" th:value="${u.screens_id}" type="checkbox"/></td>
                        <td th:text="${u.screens_id}"></td>
                        <td th:text="${u.screens_name}"></td>
                        <td th:text="${u.seating}"></td>
                        <td th:switch="${u.screens_type}">
                            <span th:case="0">小型</span>
                            <span th:case="1">中型</span>
                            <span th:case="2">中型3D</span>
                            <span th:case="3">大型</span>
                            <span th:case="4">大型3D</span>
                        </td>
                        <td>

                            <button class="btn btn-default btn-xs btn-danger btn-primary"
                                    th:onclick="Updata([[${u.screens_id}]])">修改
                            </button>
                            <button class="btn btn-default btn-xs btn-danger btn-primary" th:onclick="deleteScreens()">
                                删除
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>

        </div>
    </div>
</div>
<!--添加模板-->
<div aria-hidden="true" aria-labelledby="myModalLabel" class="modal fade" id="register" role="dialog" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button aria-hidden="true" class="close" data-dismiss="modal" type="button">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    添加电影
                </h4>
            </div>
            <form class="form-inline" id="bjy-form" method="post" name="newScreens" onsubmit="return check()"
                  th:action="@{/admin/addScreens}">
                <table class="table">
                    <tbody>
                    <tr>
                        <td>放映室名</td>
                        <td><input class="form-control" name="screens_name" placeholder="请输入放映室名" type="text"/></td>
                    </tr>
                    <tr>
                        <td>坐位数</td>
                        <td><input class="form-control" name="seating" placeholder="请输出坐位数量" type="text"/></td>
                    </tr>
                    <tr>
                        <td>放映厅类型</td>
                        <td>
                            <select class="form-control" id="screens_type" name="screens_type">
                                <option value="0">小型</option>
                                <option value="1">中型</option>
                                <option value="2">中型3D</option>
                                <option value="3">大型</option>
                                <option value="4">大型3D</option>
                            </select>
                        </td>
                    </tr>
                    <tr>

                        <td><input class="btn btn-default" type="submit" value="添加"/></td>
                        <td><input class="btn btn-default" type="reset" value="重置"/></td>
                    </tr>
                    </tbody>
                </table>
            </form>

        </div>
    </div>
</div>
</div>
<div aria-hidden="true" aria-labelledby="myModalLabel" class="modal fade" id="film_Intro" role="dialog" tabindex="-1">
    <td><textarea class="form-control" cols="20" name="film_Intro" rows="5"></textarea></td>
</div>
<script type="text/javascript">

    function registerMadel() {
        $("#register").modal("show");
    }
    //时间控件
    $(function () {
        $('#datetimepicker2').datetimepicker({
            format: 'YYYY-MM-DD hh:mm',
            locale: moment.locale('zh-cn')
        });
    });

    function deleteScreens() {
        var str = [];
        var sel = document.getElementsByName("chk");//获取checkbox的值
        console.log(sel)
        for (var i = 0; i < sel.length; i++)
            if (sel[i].checked == true)
                str.push(sel[i].value);
        if (str == "") {
            alert("请至少选择一条记录");
            return false;
        }


        // if(window.confirm("确定删除吗")){
        //     window.location="./DeleteUser?userids="+str;
        // }

        if (window.confirm("确定删除吗")) {
            $.post(getContextPath() + "/admin/deleteScreens", {screens_id: str.join(",")}, function (data) {
                window.location.reload();
            });
        }
    }

    function Updata(screens_id) {

        window.location = getContextPath() + "/admin/findIdScreens?screens_id=" + screens_id;
        // $.post("./findIdUser",{screens_id : screens_id}, function (data) {
        //     window.location.reload();
        // });
    }



</script>

</body>
</html>